package com.ych.modules.api.authorInfc.raffleTicket.controller;

import com.baomidou.mybatisplus.plugins.Page;
import com.ych.modules.api.authorInfc.raffleTicket.entity.QueryRaffleTicketEntity;
import com.ych.modules.base.dbEntity.TRaffleTicketJackpotEntity;
import com.ych.modules.base.dbEntity.TUserRaffleTicketEntity;
import com.ych.modules.base.service.ITUserRaffleTicketService;
import com.ych.utils.TLMap;
import com.ych.utils.mysqlPageUtil.PageUtils;
import com.ych.utils.serviceReturn.R;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * Created with IntelliJ IDEA.
 * Author: Usopp.tsui
 * Date: 2021/3/18
 * Time: 17:16
 * Description:
 */
@RestController("apiRaffleTicketController")
@RequestMapping("/api/auth/raffleTicket")
@Api(tags = {"API——抽奖奖券相关"})
public class RaffleTicketController {
    @Autowired
    private ITUserRaffleTicketService itUserRaffleTicketService;

    @PostMapping("/listPersonRaffleTicket")
    @ApiOperation(value = "查询个人抽奖列表", notes = "查询个人抽奖列表")
    public R<PageUtils> listPersonRaffleTicket(@RequestBody QueryRaffleTicketEntity entity) {
        try {
            entity.setUserId(TLMap.getUserId());
            Page<TRaffleTicketJackpotEntity> page = itUserRaffleTicketService.listRaffleTicket(entity);
            return new R(0, "成功", new PageUtils(page));
        } catch (Exception e) {
            return new R(1, e.getMessage(), null);
        }
    }
}
